home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / cadq_010.zip / TESTDQK.CMD < prev   
OS/2 REXX Batch file  |  1995-03-16  |  3KB  |  95 lines

  1. /* Sample REXX program demonstrating the data queue library functions */
  2. /* This sample will create a non-keyed data queue, query the data     */
  3. /* queue, send and receive one message, then delete the data queue.   */
  4.  
  5. arg dqname
  6. if dqname = '' then do
  7.   say 'A data queue name must be entered in AS/400 format.'
  8.   say 'Example: TESTDQ QGPL/TESTQ'
  9.   say
  10.   exit
  11. end
  12.  
  13. arg dqname
  14.  
  15. /* Load the data queues external utility functions */
  16. Call RxFuncAdd 'CADQLoadFuncs', 'CADQUTIL', 'CADQLoadFuncs'
  17. Call CADQLoadFuncs
  18.  
  19. /* Set translation on, peek (non-destructive read) off */
  20. Call CADQSetMode ,1,0
  21. Call ShowResult 'CADQSetMode'
  22.  
  23. /* Create a keyed data queue on the default system */
  24. /* Max length=256, FIFO sequence, no force, *ALL authority, include sender */
  25. /* Key length=5                                                            */
  26. Call CADQCreate dqname,,256,,0,0,1,"Test Keyed Data Queue",5
  27. Call ShowResult 'CADQCreate'
  28.  
  29. /* Query the new data queue */
  30. Call CADQQuery dqname
  31. Call ShowResult 'CADQQuery'
  32.  
  33. say '  Max length:' dq_maxlen
  34. say '  Sequence:  ' dq_seq
  35. say '  Force:     ' dq_force
  36. say '  Sender:    ' dq_sender
  37. say '  Text:      ' dq_text
  38. say '  Key length:' dq_keylen
  39. say
  40.  
  41. /* Clear the data queue */
  42. Call CADQClear dqname
  43. Call ShowResult 'CADQClear'
  44.  
  45. /* Send a message to the data queue */
  46. Call CADQSend dqname,,"Data queue operation successful!","DQKey"
  47. Call ShowResult 'CADQSend'
  48.  
  49. /* Receive the message from the data queue into REXX variable DQ_DATA */
  50. Call CADQReceive dqname,,2,'DQ_DATA',256,'DQ_SNDR','DQKey','EQ','DQ_KEY',5
  51. Call ShowResult 'CADQReceive'
  52.  
  53. /* Show the received queue message, sender ID, and key values */
  54. say '  Key:   ' '"'dq_key'"'
  55. say '  Sender:' '"'dq_sndr'"'
  56. say '  Data:  ' '"'dq_data'"'
  57. say
  58.  
  59. /* Delete the data queue */
  60. Call CADQDelete dqname
  61. Call ShowResult 'CADQDelete'
  62.  
  63. /* Unload all utility functions */
  64. Call RxFuncDrop 'CADQLoadFuncs'
  65. Call RxFuncDrop 'CADQCreate'
  66. Call RxFuncDrop 'CADQDelete'
  67. Call RxFuncDrop 'CADQClear'
  68. Call RxFuncDrop 'CADQPut'
  69. Call RxFuncDrop 'CADQSend'
  70. Call RxFuncDrop 'CADQReceive'
  71. Call RxFuncDrop 'CADQSetMode'
  72. Call RxFuncDrop 'CADQGetMsg'
  73. Call RxFuncDrop 'CADQQuery'
  74. Call RxFuncDrop 'CADQStop'
  75.  
  76. exit
  77.  
  78. /* Procedure ShowResult: Show the result code from the utility call */
  79. /* If a non-zero result is received, show all error messages */
  80. ShowResult:
  81.   parse arg rtn
  82.  
  83.   say rtn':' result
  84.   if result <> 0 then do
  85.     Call CADQGetMsg
  86.     do while result <> ''
  87.       say result
  88.       Call CADQGetMsg
  89.     end
  90.   end
  91.   say
  92.  
  93. return
  94.  
  95.